//隐藏边栏
var closePanel = function (id, time) {
    $("#" + id).fadeOut(time);
};

//显示边栏
var showPanel = function (id, time) {
    try {
        $("#" + id).fadeIn(time);
    }
    catch (e) {
        alert(e)
    }
};

//RGB转换为16进制（使用方式 "rgb(255,255,255)".colorHex()）
String.prototype.colorHex = function () {
    // RGB颜色值的正则
    var reg = /^(rgb|RGB)/;
    var color = this;
    if (reg.test(color)) {
        var strHex = "#";
        // 把RGB的3个数值变成数组
        var colorArr = color.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
        // 转成16进制
        for (var i = 0; i < colorArr.length; i++) {
            var hex = Number(colorArr[i]).toString(16);
            if (hex === "0") {
                hex += hex;
            }
            strHex += hex;
        }
        return strHex;
    } else {
        return String(color);
    }
};

//16进制转换为RGB（"#fff".colorRgb(); ）
String.prototype.colorRgb = function (transparent) {
    // 16进制颜色值的正则
    var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
    // 把颜色值变成小写
    var color = this.toLowerCase();
    if (reg.test(color)) {
        // 如果只有三位的值，需变成六位，如：#fff => #ffffff
        if (color.length === 4) {
            var colorNew = "#";
            for (var i = 1; i < 4; i += 1) {
                colorNew += color.slice(i, i + 1).concat(color.slice(i, i + 1));
            }
            color = colorNew;
        }
        // 处理六位的颜色值，转为RGB
        var colorChange = [];
        for (var i = 1; i < 7; i += 2) {
            colorChange.push(parseInt("0x" + color.slice(i, i + 2)));
        }

        if (transparent != undefined) {
            return "rgba(" + colorChange.join(",") + "," + transparent + ")";
        }
        else {
            return "RGB(" + colorChange.join(",") + ")";
        }

    } else {
        return color;
    }
};

//显示浮动层
function showfloat(id) {
    $('#' + id).show();
}

//隐藏浮动层
function hidefloat(id) {
    $('#' + id).hide();
}

//获取请求头
function getHeader() {

    let vHeader = {};

    if (window.location.host.indexOf("localhost") > -1) {

    }
    else {

        let vAppID = USER_INFO.RealName;
        let vTimestamp = DateUtil.now();
        let vSign = hex_md5(vAppID + vTimestamp);

        vHeader = {
            appid: vAppID,
            timestamp: vTimestamp,
            sign: vSign
        }
    }

    return vHeader;
}


